/****************************************************************************
 *   This file is part of Q2D.                                              *
 *                                                                          *
 *   Q2D is free software: you can redistribute it and/or modify            *
 *   it under the terms of the GNU General Public License as published by   *
 *   the Free Software Foundation, either version 3 of the License, or      *
 *   (at your option) any later version.                                    *
 *                                                                          *
 *   Q2D is distributed in the hope that it will be useful,                 *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *   GNU General Public License for more details.                           *
 *                                                                          *
 *   You should have received a copy of the GNU General Public License      *
 *   along with Q2D.  If not, see <http://www.gnu.org/licenses/>.           *
 *                                                                          *
 ****************************************************************************/

#include "weapon.h"

Weapon::Weapon()
{
        hash = new QCryptographicHash(QCryptographicHash::Md5);
}

uint Weapon::getId()
{
        return id;
}

void Weapon::setId(uint id)
{
        this->id = id;
}

QString Weapon::getHexHash() const
{
        QByteArray array;
        array.append(name.toUtf8());

        hash->reset();
        hash->addData(array);
        return QString(hash->result().toHex());
}

QString Weapon::getName()
{
        return name;
}

void Weapon::setName(QString name)
{
        this->name = name;
}

QString Weapon::getDescription()
{
        return description;
}

void Weapon::setDescription(QString description)
{
        this->description = description;
}

WeaponType * Weapon::getWeaponType()
{
        return &type;
}

void Weapon::setWeaponType(WeaponType type)
{
        this->type = type;
}

qreal Weapon::getPrice()
{
        return price;
}

void Weapon::setPrice(qreal price)
{
        this->price = price;
}

QString Weapon::getDamageSmall()
{
        return damageSmall;
}

void Weapon::setDamageSmall(QString damage)
{
        this->damageSmall = damage;
}

QString Weapon::getDamageMedium()
{
        return damageMedium;
}

void Weapon::setDamageMedium(QString damage)
{
        this->damageMedium = damage;
}

uint Weapon::getCriticalFactor()
{
        return criticalFactor;
}

void Weapon::setCriticalFactor(uint factor)
{
        this->criticalFactor = factor;
}

uint Weapon::getCriticalRange()
{
        return criticalRange;
}

void Weapon::setCriticalRange(uint range)
{
        this->criticalRange = range;
}

qreal Weapon::getRange()
{
        return range;
}

void Weapon::setRange(qreal range)
{
        this->range = range;
}

qreal Weapon::getWeight()
{
        return weight;
}

void Weapon::setWeight(qreal weight)
{
        this->weight = weight;
}

WeaponDamageType * Weapon::getDamageType()
{
        return &damageType;
}

void Weapon::setWeaponDamageType(WeaponDamageType type)
{
        this->damageType = type;
}

int Weapon::getBaBonus()
{
        return baBonus;
}

void Weapon::setBaBonus(int bonus)
{
        this->baBonus = bonus;
}

int Weapon::getDmgBonus()
{
        return dmgBonus;
}

void Weapon::setDmgBonus(int bonus)
{
        this->dmgBonus = bonus;
}

bool Weapon::operator==(const Weapon &w) const
{
        QString s1 = this->getHexHash();
        QString s2 = w.getHexHash();

        if(s1 == s2)
                return true;
        else
                return false;
}
